wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
NodeUtil Class Reference

Public Member Functions

 NodeUtil ()
 
 getPath (&$node)
 
 getConnectionToAncestor (&$tplNode, $ancestorType, $nodes=null)
 
 getConnectionToDescendant (&$tplNode, $descendantType, $nodes=null)
 
 getNodeQuery ($nodeType)
 
 getSelfQuery ($nodeType, $oid)
 
 getParentQuery ($parentType, &$childNode)
 
 getChildQuery (&$parentNode, $childType)
 
 getPossibleParents (&$realNode, &$tplNode)
 
 getPossibleChildren (&$realNode, &$tplNode, $resolveManyToMany=true)
 
 getRealSubjectType (&$proxy, $parentType)
 
 getDisplayValueNames (&$node)
 
 getDisplayValue (&$node, $useDisplayType=false, $language=null, $values=null)
 
 getDisplayValues (&$node, $useDisplayType=false, $language=null, $values=null)
 
 getDisplayNameFromType ($type)
 
 getDescriptionFromType ($type)
 
 getInputControl (&$node, $name, $dataType=null, $templateNode=null, $addEmptyValue=false)
 
 getInputControlName (&$node, $name, $dataType=null)
 
 getValueDefFromInputControlName ($name)
 
 completeNode (&$node)
 
 setSortProperties (&$nodeList)
 
 makeNodeUrlsRelative (&$node, $baseUrl, $recursive=true)
 
 makeValueUrlsRelative (&$node, $valueName, $dataType, $baseUrl)
 
 renderValues (&$nodes, $language=null)
 
 renderValue (&$node, $valueName, $dataType, $formUtil)
 
 translateValues (&$nodes, $language=null)
 
 translateValue (&$node, $valueName, $dataType, $formUtil)
 
 removeNonDisplayValues (&$node)
 

Public Attributes

 $_formUtil = null
 

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 41 of file class.NodeUtil.php.

Member Function Documentation

NodeUtil::NodeUtil ( )

Constructor

Definition at line 48 of file class.NodeUtil.php.

Referenced by makeNodeUrlsRelative(), renderValues(), and translateValues().

NodeUtil::getPath ( $node)

Get the path to a given Node (from a root node).

Parameters
nodeThe Node to find the path for
Returns
An array containing the nodes in the path

Definition at line 58 of file class.NodeUtil.php.

References BUILDDEPTH_SINGLE, PersistenceFacade\getInstance(), and PersistenceFacade\isValidOID().

+ Here is the call graph for this function:

NodeUtil::getConnectionToAncestor ( $tplNode,
  $ancestorType,
  $nodes = null 
)

Get the node types that connect a type to a ancestor type.

Parameters
tplNodeThe node to start from
ancestorTypeThe type to connect to
nodesInternal use only
Returns
An array of connecting nodes or null (if no connection exists)

Definition at line 86 of file class.NodeUtil.php.

References PersistenceFacade\getInstance(), and PersistenceFacade\getOIDParameter().

Referenced by StringQuery\buildQuery().

+ Here is the call graph for this function:

NodeUtil::getConnectionToDescendant ( $tplNode,
  $descendantType,
  $nodes = null 
)

Get the node types that connect a type to a descendant type.

Note
tplNode must be loaded/created with at least BUILDDEPTH = 1
Parameters
tplNodeThe node to start from
descendantTypeThe type to connect to
nodesInternal use only
Returns
An array of connecting nodes or null (if no connection exists)

Definition at line 128 of file class.NodeUtil.php.

References PersistenceFacade\getInstance(), and PersistenceFacade\getOIDParameter().

Referenced by StringQuery\buildQuery().

+ Here is the call graph for this function:

NodeUtil::getNodeQuery (   $nodeType)

Get the query used to select all Nodes of a type.

Parameters
nodeTypeThe Node type
Returns
The serialized query string to be used with ObjectQuery::executeString.

Definition at line 167 of file class.NodeUtil.php.

References PersistenceFacade\createObjectQuery().

Referenced by AsyncPagingController\getObjects(), and SortController\sortAll().

+ Here is the call graph for this function:

NodeUtil::getSelfQuery (   $nodeType,
  $oid 
)

Get the query used to select a special Node.

Parameters
nodeTypeThe Node type
oidThe object id of the node
Returns
The serialized query string to be used with ObjectQuery::executeString.

Definition at line 178 of file class.NodeUtil.php.

References PersistenceFacade\createObjectQuery(), PersistenceFacade\decomposeOID(), and PersistenceFacade\getInstance().

+ Here is the call graph for this function:

NodeUtil::getParentQuery (   $parentType,
$childNode 
)

Get the query used to select all parent Nodes of a given type.

Parameters
parentTypeThe parent type
childNodeThe Node to select the parents for
Returns
The serialized query string to be used with ObjectQuery::executeString.

Definition at line 197 of file class.NodeUtil.php.

References PersistenceFacade\createObjectQuery(), and PersistenceFacade\getInstance().

+ Here is the call graph for this function:

NodeUtil::getChildQuery ( $parentNode,
  $childType 
)

Get the query used to select all child Nodes of a given type.

Parameters
parentNodeThe Node to select the children for
childTypeThe child type
Returns
The serialized query string to be used with ObjectQuery::executeString.

Definition at line 217 of file class.NodeUtil.php.

References PersistenceFacade\createObjectQuery().

+ Here is the call graph for this function:

NodeUtil::getPossibleParents ( $realNode,
$tplNode 
)

Get allowed parent types for a Node by comparing the existing parents of realNode with the possible parents of tplNode.

Parameters
realNodeA reference to the Node that defines the existing parents (property parentoids must be given)
tplNodeA reference to the Node that defines the possible parents (property parentoids must be given)
Returns
An associative array with the parent type as key and a template of the parent as values.
Note
: The template has the following extra properties (use Node::getProperty()):
  • parentOID gives the object id of the parent object if an instance already assigned to that parent type (per definition only one instance is assignable to a parent type)
  • canAssociate (boolean) indicating if an instance may be associated (depends on the navigability from the parent)
  • composition (boolean) indicating if the parent child relation is a composition

Definition at line 242 of file class.NodeUtil.php.

References PersistenceFacade\getInstance(), and PersistenceFacade\getOIDParameter().

Referenced by DisplayController\executeKernel(), and AssociateController\isDirectAssociation().

+ Here is the call graph for this function:

NodeUtil::getPossibleChildren ( $realNode,
$tplNode,
  $resolveManyToMany = true 
)

Get allowed child types for a Node by comparing the existing children of realNode with the possible children of tplNode.

Parameters
realNodeA reference to the Node that defines the existing children (property childoids must be given)
tplNodeA reference to the Node that defines the possible children (children must be included already)
resolveManyToManyTrue/False wether for all many to many children the real subject types should be returned [default: true]
Returns
An associative array with the child type as key and a template of the child as values.
Note
: The template has the following extra properties (use Node::getProperty()):
  • canCreate (boolean) indicating if an instance may be created (depends on the multiplicity)
  • realSubjectType the type of the real subject if the template is acting as proxy (many to many instance)

Definition at line 292 of file class.NodeUtil.php.

References PersistenceFacade\getInstance(), PersistenceFacade\getOIDParameter(), and getRealSubjectType().

Referenced by DisplayController\executeKernel(), and CopyController\validate().

+ Here is the call graph for this function:

NodeUtil::getRealSubjectType ( $proxy,
  $parentType 
)

Get the real subject type for a proxy node, that is a many to many instance. A many to many instance serves as proxy between a client and a real subject, where the client is the parent node in this case and the proxy is the child node.

Parameters
proxyThe (many to many) proxy node
parentTypeThe parent type
Returns
The type

Definition at line 349 of file class.NodeUtil.php.

Referenced by getPossibleChildren(), and AsyncPagingController\modifyModel().

NodeUtil::getDisplayValueNames ( $node)

Get the display value names of a Node.

Parameters
nodeThe Node instance
Returns
An array of value names

Definition at line 380 of file class.NodeUtil.php.

Referenced by removeNonDisplayValues().

NodeUtil::getDisplayValue ( $node,
  $useDisplayType = false,
  $language = null,
  $values = null 
)

Get the display value for a Node defined by the 'display_value' property that may reference values of subnodes. 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|Comment/text' shows the name of the Node together with the text of the first Comment child

Note
If display_value is ambiguous because a parent has more than one children of a given type than the first child of that type will be chosen for display.
Parameters
nodeA reference to the Node to display
useDisplayTypeTrue/False wether to use the display types that are associated with the values which the display value contains [default: false]
languageThe lanugage if values should be localized. Optional, default is Localization::getDefaultLanguage()
valuesAn assoziative array holding key value pairs that the display node's values should match [maybe null].
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
  • attributes: a string of attributes used in the HTML definition (e.g. 'height="50"')
Returns
The display string
See Also
DefaultValueRenderer::renderValue

Definition at line 409 of file class.NodeUtil.php.

References getDisplayValues().

Referenced by SimplePagingController\getDisplayText(), NodeListController\getDisplayText(), TreeViewController\getDisplayText(), Node\getDisplayValue(), SOAPController\soapAdvancedSearch(), and SOAPController\soapSearch().

+ Here is the call graph for this function:

NodeUtil::getDisplayValues ( $node,
  $useDisplayType = false,
  $language = null,
  $values = null 
)

Does the same as DefaultValueRenderer::getDisplayValue() but returns the display value as associative array

Parameters
nodeA reference to the Node to display
useDisplayTypeTrue/False wether to use the display types that are associated with the values which the display value contains [default: false]
languageThe lanugage if values should be localized. Optional, default is Localization::getDefaultLanguage()
valuesAn assoziative array holding key value pairs that the display node's values should match [maybe null].
Returns
The display array

Definition at line 421 of file class.NodeUtil.php.

References $GLOBALS, BUILDDEPTH_SINGLE, ObjectFactory\getInstance(), PersistenceFacade\getInstance(), Localization\getInstance(), PersistenceFacade\isKnownType(), and WCMFException\throwEx().

Referenced by getDisplayValue(), and Node\getDisplayValues().

+ Here is the call graph for this function:

NodeUtil::getDisplayNameFromType (   $type)

Get the display name for a Node type.

Parameters
typeThe name of the type
Returns
The display string

Definition at line 564 of file class.NodeUtil.php.

References BUILDDEPTH_SINGLE, and PersistenceFacade\getInstance().

+ Here is the call graph for this function:

NodeUtil::getDescriptionFromType (   $type)

Get the description for a Node type.

Parameters
typeThe name of the type
Returns
The description

Definition at line 575 of file class.NodeUtil.php.

References BUILDDEPTH_SINGLE, and PersistenceFacade\getInstance().

+ Here is the call graph for this function:

NodeUtil::getInputControl ( $node,
  $name,
  $dataType = null,
  $templateNode = null,
  $addEmptyValue = false 
)

Get a HTML input control for a given node value. The control is defined by the 'input_type' property of the value. The property 'is_editable' is used to determine wether the control should be enabled or not.

Parameters
nodeA reference to the Node which contains the value
nameThe name of the value to construct the control for
dataTypeThe type of the value [optional] (if type is omitted the first value of any type that matches will be used)
templateNodeA Node which contains the value definition (if not given the definition will be taken from the node parameter) [optional]
addEmptyValueTrue/False if this is set true, an additional empty value is added to the input control (if not given no empty value will be added) [optional]
Returns
The HTML control string (see FormUtil::getInputControl())

Definition at line 595 of file class.NodeUtil.php.

References BUILDDEPTH_SINGLE, getInputControlName(), and PersistenceFacade\getInstance().

+ Here is the call graph for this function:

NodeUtil::getInputControlName ( $node,
  $name,
  $dataType = null 
)

Get a HTML input control name for a given node value (see FormUtil::getInputControl()).

Parameters
nodeA reference to the Node which contains the value
nameThe name of the value to construct the control for
dataTypeThe type of the value [optional] (if type is omitted the first value of any type that matches will be used)
Returns
The HTML control name string in the form value-<datatype>-<name>-<oid>

Definition at line 630 of file class.NodeUtil.php.

References FormUtil\getInputFieldDelimiter().

Referenced by getInputControl().

+ Here is the call graph for this function:

NodeUtil::getValueDefFromInputControlName (   $name)

Get the node value definition from a HTML input control name.

Parameters
nameThe name of input control in the format defined by getInputControlName
Returns
An associative array with keys 'oid', 'name', 'dataType' or null if the name is not valid If the dataType is empty, it defaults to DATATYPE_ATTRIBUTE

Definition at line 641 of file class.NodeUtil.php.

References DATATYPE_ATTRIBUTE, and FormUtil\getInputFieldDelimiter().

Referenced by HTMLFormat\deserialize().

+ Here is the call graph for this function:

NodeUtil::completeNode ( $node)

Add the missing attributes to a Node. The state remains the same.

Parameters
nodeA reference to the Node to complete

Definition at line 669 of file class.NodeUtil.php.

References BUILDDEPTH_SINGLE, DATATYPE_ATTRIBUTE, and PersistenceFacade\getInstance().

+ Here is the call graph for this function:

NodeUtil::setSortProperties ( $nodeList)

Sort a list of Nodes and set the sort properties on Nodes of a given list. The two attributes (DATATPE_IGNORE) 'hasSortUp', 'hasSortDown' (values (false,true)) will be added to each Node depending on its list position. If applicable the attributes (DATATPE_IGNORE) 'prevoid' and 'nextoid' resp. will be added to denote the neighboured Nodes. The attributes will only be added if a Node has a sortkey value (DATATPE_IGNORE).

Parameters
nodeListA reference to the list of Nodes

Definition at line 693 of file class.NodeUtil.php.

References DATATYPE_IGNORE, and Node\sort().

Referenced by NodeListController\modifyModel(), and AsyncPagingController\modifyModel().

+ Here is the call graph for this function:

NodeUtil::makeNodeUrlsRelative ( $node,
  $baseUrl,
  $recursive = true 
)

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
recursiveTrue/False wether to recurse into child Nodes or not (default: true)

Definition at line 726 of file class.NodeUtil.php.

References NodeUtil().

+ Here is the call graph for this function:

NodeUtil::makeValueUrlsRelative ( $node,
  $valueName,
  $dataType,
  $baseUrl 
)

Make the urls matching a given base url in a Node value relative.

Parameters
nodeA reference to the Node the holds the value
valueNameThe name of the value
dataTypeThe dataType of the value
baseUrlThe baseUrl to which matching urls will be made relative

Definition at line 740 of file class.NodeUtil.php.

References StringUtil\getUrls().

+ Here is the call graph for this function:

NodeUtil::renderValues ( $nodes,
  $language = null 
)

Render all values in a list of Nodes using the DefaultValueRenderer.

Note
Values will be translated before rendering using FormUtil::translateValue
Parameters
nodesA reference to the array of Nodes
languageThe language code, if the translated values should be localized. Optional, default is Localization::getDefaultLanguage()

Definition at line 770 of file class.NodeUtil.php.

References NodeUtil().

Referenced by SearchController\modifyModel(), and AsyncPagingController\modifyModel().

+ Here is the call graph for this function:

NodeUtil::renderValue ( $node,
  $valueName,
  $dataType,
  $formUtil 
)

Callback to render a Node value

See Also
NodeProcessor
Note
This method is used internally only

Definition at line 787 of file class.NodeUtil.php.

References DATATYPE_ATTRIBUTE.

NodeUtil::translateValues ( $nodes,
  $language = null 
)

Translate all values in a list of Nodes using the DefaultValueRenderer.

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 Localization::getDefaultLanguage()

Definition at line 814 of file class.NodeUtil.php.

References NodeUtil().

Referenced by DisplayController\executeKernel(), and BatchDisplayController\loadNode().

+ Here is the call graph for this function:

NodeUtil::translateValue ( $node,
  $valueName,
  $dataType,
  $formUtil 
)

Callback to translate a Node value

See Also
NodeProcessor
Note
This method is used internally only

Definition at line 831 of file class.NodeUtil.php.

References DATATYPE_ATTRIBUTE.

NodeUtil::removeNonDisplayValues ( $node)

Remove all values from a Node that are not a display value and don't have DATATYPE_IGNORE.

Parameters
nodeThe Node instance

Definition at line 847 of file class.NodeUtil.php.

References getDisplayValueNames().

Referenced by SearchController\modifyModel(), and AsyncPagingController\modifyModel().

+ Here is the call graph for this function:

Member Data Documentation

NodeUtil::$_formUtil = null

Definition at line 43 of file class.NodeUtil.php.


The documentation for this class was generated from the following file: