Detailed Description

NodeUtil provides services for the Node class.

All methods are static.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 28 of file NodeUtil.php.

Static Public Member Functions

static getConnections ($type, $otherRole, $otherType, $hierarchyType='all')
 
static getRelationQueryCondition ($node, $otherRole)
 
static getDisplayValue (Node $node, $language=null)
 
static getDisplayValues (Node $node, $language=null)
 
static makeNodeUrlsRelative (Node $node, $baseUrl, $recursive=true)
 
static translateValues (&$nodes, $language=null)
 
static removeNonDisplayValues (Node $node)
 
static removeNonPkValues (Node $node)
 

Static Protected Member Functions

static getConnectionsImpl ($type, $otherRole, $otherType, $hierarchyType, array &$result=array(), array $currentPath=array())
 

Member Function Documentation

static getConnections (   $type,
  $otherRole,
  $otherType,
  $hierarchyType = 'all' 
)
static

Get the shortest paths that connect a type to another type.

Parameters
$typeThe type to start from
$otherRoleThe role of the type at the other end (maybe null, if only type shoudl match)
$otherTypeThe type at the other end (maybe null, if only role shoudl match)
$hierarchyTypeThe hierarchy type that the other type has in relation to this type 'parent', 'child', 'undefined' or 'all' to get all relations (default: 'all')
Returns
An array of PathDescription instances

Definition at line 39 of file NodeUtil.php.

static getConnectionsImpl (   $type,
  $otherRole,
  $otherType,
  $hierarchyType,
array &  $result = array(),
array  $currentPath = array() 
)
staticprotected

Get the relations that connect a type to another type.

Parameters
$typeThe type to start from
$otherRoleThe role of the type at the other end (maybe null, if only type shoudl match)
$otherTypeThe type at the other end (maybe null, if only role shoudl match)
$hierarchyTypeThe hierarchy type that the other type has in relation to this type 'parent', 'child', 'undefined' or 'all' to get all relations (default: 'all')
$resultArray of PathDescriptions after execution
$currentPathInternal use only

Definition at line 67 of file NodeUtil.php.

static getRelationQueryCondition (   $node,
  $otherRole 
)
static

Get the query condition used to select all related Nodes of a given role.

Parameters
$nodeThe Node to select the relatives for
$otherRoleThe role of the other nodes
Returns
The condition string to be used with StringQuery.

Definition at line 117 of file NodeUtil.php.

static getDisplayValue ( Node  $node,
  $language = null 
)
static

Get the display value for a Node defined by the 'display_value' property.

If the 'display_value' is an array ('|' separated strings) the pieces will be put together with ' - '. If search for 'display_value' gives no result the function returns an empty string. Example: 'name|text' shows the name of the Node together with the content of the text attribute

Parameters
$nodeA reference to the Node to display
$languageThe language if values should be localized. Optional, default is Localization::getDefaultLanguage()
Note
The display type is configured via the display_type property of a value. It describes how the value should be displayed. The description is of the form
type
or
type[attributes]
  • type: text|image|link
  • attributes: a string of attributes used in the HTML definition (e.g. 'height="50"')
Returns
The display string

Definition at line 156 of file NodeUtil.php.

static getDisplayValues ( Node  $node,
  $language = null 
)
static

Does the same as NodeUtil::getDisplayValue but returns the display value as associative array.

Parameters
$nodeA reference to the Node to display
$languageThe language if values should be localized. Optional, default is Localization::getDefaultLanguage()
Returns
The display array

Definition at line 166 of file NodeUtil.php.

static makeNodeUrlsRelative ( Node  $node,
  $baseUrl,
  $recursive = true 
)
static

Make all urls matching a given base url in a Node relative.

Parameters
$nodeA reference to the Node the holds the value
$baseUrlThe baseUrl to which matching urls will be made relative
$recursiveBoolean whether to recurse into child Nodes or not (default: true)

Definition at line 207 of file NodeUtil.php.

static translateValues ( $nodes,
  $language = null 
)
static

Translate all list values in a list of Nodes.

Note
Translation in this case refers to mapping list values from the key to the value and should not be confused with localization, although values maybe localized using the language parameter.
Parameters
$nodesA reference to the array of Nodes
$languageThe language code, if the translated values should be localized. Optional, default is Localizat$objectgetDefaultLanguage()

Definition at line 253 of file NodeUtil.php.

static removeNonDisplayValues ( Node  $node)
static

Remove all values from a Node that are not a display value.

Parameters
$nodeThe Node instance

Definition at line 281 of file NodeUtil.php.

static removeNonPkValues ( Node  $node)
static

Remove all values from a Node that are not a primary key value.

Parameters
$nodeThe Node instance

Definition at line 296 of file NodeUtil.php.