Welcompose
[ class tree: Welcompose ] [ index: Welcompose ] [ all elements ]

Class: Utility_NestedSet

Source Location: /utility_classes/nestedset.class.php

Class Overview




Variables

Methods



Class Details

[line 42]


[ Top ]


Class Variables

static $instance =  null

[line 49]

Singleton



Tags:

access:  public

Type:   object


[ Top ]

$base =  null

[line 56]

Reference to base class



Tags:

access:  public

Type:   object


[ Top ]



Class Methods


constructor __construct [line 63]

Utility_NestedSet __construct( )

Start instance of base class, load configuration and establish database connection. Please don't call the constructor direcly, use the singleton pattern instead.



Tags:

access:  public


[ Top ]

method changeNavigationOfNodeInTree [line 2962]

bool changeNavigationOfNodeInTree( int $navigation, int $node_id, int $new_navigation)

Takes node out of a navigation and puts it at the end of

another navigation. Takes the id of the "old" navigation as first argument, the id of the root node to move as second argument and the id of the new navigation as third and last argument.




Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id
int   $node_id   Node id
int   $new_navigation   New navigation id

[ Top ]

method changeNavigationOfRootNode [line 2730]

bool changeNavigationOfRootNode( int $navigation, int $node_id, int $new_navigation)

Takes root node out of a navigation and puts it at the end of

another navigation. Takes the id of the "old" navigation as first argument, the id of the root node to move as second argument and the id of the new navigation as third and last argument.




Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id
int   $node_id   Node id
int   $new_navigation   New navigation id

[ Top ]

method countNodes [line 3595]

int countNodes( [array $params = array()])

Method to count the nodes. Takes key=>value array with count params as first argument. Returns int.

List of supported params:

  • navigation, int, optional: Navigation id
  • root_node, int, optional: Root node id
  • parent, int, optional: Parent node id




Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

array   $params   Count params

[ Top ]

method createNode [line 91]

int createNode( int $navigation, [int $reference = null], [int $position = null])

Wrapper around all the other create* functions. Decides which of all the different create* functions to use.



Tags:

return:  Insert id
throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id
int   $reference   Reference node id
int   $position   Position information

[ Top ]

method createNodeAbove [line 331]

int createNodeAbove( int $navigation, int $reference)

Creates node above existing node. Takes the navigation id as first argument, the id of the reference node above that the new node will be positioned as second argument. Returns insert id.



Tags:

return:  Insert id
throws:  
access:  public


Parameters:

int   $navigation   Navigation id
int   $reference   Reference node id

[ Top ]

method createNodeBelow [line 423]

int createNodeBelow( int $navigation, int $reference)

Creates node below existing node (~ creates new branch). Takes the navigation id as first argument, the id of the reference node where the sub node will be attached to as second argument. Returns insert id.



Tags:

return:  Insert id
throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id
int   $reference   Reference node id

[ Top ]

method createRootNode [line 204]

int createRootNode( int $navigation, [int $reference = null], [int $position = null])

Creates new root node. Takes the navigation id as first argument, the id of the reference node after or before the new node will be created as second argument and the positioning information as third argument.

Returns insert id of the new node.

Supported constants for parameter position:

  • UTILITY_NESTEDSET_CREATE_BEFORE: node will be created before reference node
  • UTILITY_NESTEDSET_CREATE_AFTER: node will be created after reference node




Tags:

return:  Insert id
throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id
int   $reference   Reference node id
int   $position   Position information

[ Top ]

method deleteNode [line 132]

int deleteNode( int $navigation, int $node)

Wrapper around the different delete* functions. Decides which of all the different delete functions to use.



Tags:

return:  Amount of affected rows
throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id
int   $node   Node id

[ Top ]

method deleteNodeInTree [line 3317]

int deleteNodeInTree( int $navigation, int $node_id)

Removes node. Takes the navigation id as first argument, the id of the node to delete as second argument. Returns amount of affected rows.



Tags:

return:  Amount of affected rows
throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id
int   $node_id   Node id

[ Top ]

method deleteRootNode [line 3096]

int deleteRootNode( int $navigation, int $node_id)

Removes root node. Takes the navigation id as first argument, the id of the root node to delete as second argument. Returns amount of affected rows.



Tags:

return:  Amount of affected rows
throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id
int   $node_id   Node id

[ Top ]

method moveDownAcrossTrees [line 2081]

bool moveDownAcrossTrees( int $navigation, int $node_id)

Moves node down across a tree. Takes the navigation id as first argument, the id of the node to move as second argument. Returns boolean true.



Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id
int   $node_id   Node id

[ Top ]

method moveDownInTree [line 2315]

bool moveDownInTree( int $navigation, int $node_id)

Moves node down in tree. Takes the navigation id as first argument, the id of the node to move as second argument. Returns boolean true.



Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id
int   $node_id   Node id

[ Top ]

method moveNode [line 160]

bool moveNode( int $navigation, int $node, [string $direction = "down"])

Wrapper around the different move* functions. Deciedes which of all the different move functions to use.



Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id
int   $node   Node id
string   $direction   Move direction

[ Top ]

method moveUpAcrossTrees [line 510]

bool moveUpAcrossTrees( int $navigation, int $node_id)

Moves node up across two trees. Takes the navigation id as first argument, the id of the node to move as second argument. Returns boolean true.

Attention: Is only able to move nodes with a lft between 1 and 2.




Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation Id
int   $node_id   Node id

[ Top ]

method moveUpInTree [line 1620]

bool moveUpInTree( int $navigation, int $node_id)

Moves node up in tree. Takes the navigation id as first argument, the id of the node to move as second argument.

Returns boolean true.

Attention: Cannot move nodes with lft < 2.




Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id
int   $node_id   Node id

[ Top ]

method node_exists [line 4040]

bool node_exists( int $node, [int $navigation = null])

Checks whether a node exists or not. Takes the node id as first argument and the navigation id as optional second argument.

Returns bool.




Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

int   $node   Node id
int   $navigation   Navigation id

[ Top ]

method root_node [line 4090]

bool root_node( int $node, [int $navigation = null])

Tests whether a node is a root node or not. Takes the node id as first argument and the navigation id as optional second argument.

Returns bool.




Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

int   $node   Node id
int   $navigation   Navigation id

[ Top ]

method selectMaxSorting [line 3963]

int selectMaxSorting( int $navigation)

Returns highest value in the sorting column for the given navigation. Takes the navigation id as first argument. Returns int.



Tags:

return:  Sorting value
throws:  Utility_NestedSetException
access:  protected


Parameters:

int   $navigation   Navigation id

[ Top ]

method selectMinSorting [line 4001]

int selectMinSorting( int $navigation)

Returns smallest value in the sorting column for the given navigation. Takes the navigation id as first argument. Returns int.



Tags:

return:  Sorting value
throws:  Utility_NestedSetException
access:  protected


Parameters:

int   $navigation   Navigation id

[ Top ]

method selectNode [line 3452]

array selectNode( int $id)

Selects node. Takes the node id as first argument. Returns array.



Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

int   $id   Node id

[ Top ]

method selectNodes [line 3505]

array selectNodes( [array $params = array()])

Method to select one or more nodes. Takes key=>value array with select params as first argument. Returns array.

List of supported params:

  • navigation, int, optional: Navigation id
  • root_node, int, optional: Root node id
  • parent, int, optional: Parent node id
  • start, int, optional: row offset
  • limit, int, optional: amount of rows to return




Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

array   $params   Select params

[ Top ]

method selectSiblingAbove [line 3669]

array selectSiblingAbove( int $navigation, int $reference)

Selects node above reference node. Takes the navigation id as first argument, the id of the reference node as second argument.

Returns array with complete information about sibling.




Tags:

throws:  Utility_NestedSetExceptio
access:  protected


Parameters:

int   $navigation   Navigation id
int   $reference   Reference node id

[ Top ]

method selectSiblingAboveOneLevelDeeper [line 3744]

array selectSiblingAboveOneLevelDeeper( int $navigation, int $reference)

Selects sibling above the reference node that's one level deeper than the current node. Takes the navigation id as first argument, the reference node id as second argument. Returns array with full node information.



Tags:

throws:  Utility_NestedSetException
access:  protected


Parameters:

int   $navigation   Navigation id
int   $reference   Reference node id

[ Top ]

method selectSiblingAboveOneLevelHigher [line 3817]

array selectSiblingAboveOneLevelHigher( int $navigation, int $reference)

Selects sibling above the reference node that's one level higher than the current node. Takes the navigation id as first argument, the id of the reference node as second argument. Returns array with full node information.



Tags:

throws:  Utility_NestedSetException
access:  protected


Parameters:

int   $navigation   Navigation id
int   $reference   Reference node id

[ Top ]

method selectSiblingBelow [line 3891]

array selectSiblingBelow( int $navigation, int $reference)

Select sibling below reference node. Takes the navigation id as first argument and the id of the reference node as second argument. Returns array with full node information.



Tags:

throws:  Utility_NestedSetException
access:  protected


Parameters:

int   $navigation   Navigation id
int   $reference   Reference node id

[ Top ]

method testConsistency [line 4122]

bool testConsistency( int $navigation)

Executes consistency check on a a navigationt tree. Takes the navigation id as first argument. Returns bool.



Tags:

throws:  Utility_NestedSetException
access:  public


Parameters:

int   $navigation   Navigation id

[ Top ]

method testForRootNodes [line 4204]

bool testForRootNodes( array $whole_tree)

Tests if there's at least one root node in the navigation tree. Takes an array with all nodes of a navigation (as returned by selectNodes()) as first argument.

Returns bool.




Tags:

throws:  Utility_NestedSetException
access:  protected


Parameters:

array   $whole_tree   Navigation tree

[ Top ]

method testNestedSets [line 4234]

bool testNestedSets( array $whole_tree)

Tests if the nested set structure is valid. Takes an array with all nodes of a navigation (as returned by selectNodes()) as first argument. Returns bool.



Tags:

throws:  Utility_NestedSetException
access:  protected


Parameters:

array   $whole_tree   Navigation tree

[ Top ]

method testSanity [line 4158]

bool testSanity( array $whole_tree)

Tests if all the numbers and identifiers in the navigation tree seem to make sense.

Takes an array with all nodes of a navigation (as returned by selectNodes()) as first argument. Returns bool.




Tags:

throws:  Utility_NestedSetException
access:  protected


Parameters:

array   $whole_tree   Navigation tree

[ Top ]


Documentation generated on Sun, 08 Jan 2012 17:51:55 +0100 by phpDocumentor 1.4.3