[ Index ] |
|
Code source de SPIP Agora 1.4 |
[Code source] [Imprimer] [Statistiques]
(pas de description)
Poids: | 2505 lignes (90 kb) |
Inclus ou requis: | 0 fois |
Référencé: | 0 fois |
Nécessite: | 0 fichiers |
DB_NestedSet:: (46 méthodes):
DB_NestedSet()
_DB_NestedSet()
getAllNodes()
getRootNodes()
getBranch()
getParents()
getParent()
getSiblings()
getChildren()
getSubBranch()
pickNode()
isParent()
createRootNode()
createSubNode()
createLeftNode()
createRightNode()
deleteNode()
updateNode()
moveTree()
_moveAcross()
_moveCleanup()
_moveRoot2Root()
_secSort()
_secSortCollect()
_addSQL()
_getSelectFields()
_processResultSet()
_testFatalAbort()
_raiseError()
addListener()
removeListener()
triggerEvent()
apiVersion()
setAttr()
setsortMode()
setDbOption()
testLock()
_setLock()
_releaseLock()
_lockGC()
_values2UpdateQuery()
_values2InsertQuery()
_verifyUserValues()
_debugMessage()
_getMessage()
convertTreeModel()
DB_NestedSet_Node:: (2 méthodes):
DB_NestedSet_Node()
setAttr()
Classe: DB_NestedSet - X-Ref
DB_NestedSet is a class for handling nested setsDB_NestedSet($params) X-Ref |
Constructor param: array $params Database column fields which should be returned return: void |
_DB_NestedSet() X-Ref |
PEAR Destructor Releases all locks Closes open database connections return: void |
getAllNodes($keepAsArray = false, $aliasFields = true, $addSQL = array() X-Ref |
Pas de description |
getRootNodes($keepAsArray = false, $aliasFields = true, $addSQL = array() X-Ref |
Fetches the first level (the rootnodes) of the NestedSet param: bool $keepAsArray (optional) Keep the result as an array or transform it into param: bool $aliasFields (optional) Should we alias the fields so they are the names param: array $addSQL (optional) Array of additional params to pass to the query. return: mixed False on error, or an array of nodes |
getBranch($id, $keepAsArray = false, $aliasFields = true, $addSQL = array() X-Ref |
Fetch the whole branch where a given node id is in param: int $id The node ID param: bool $keepAsArray (optional) Keep the result as an array or transform it into param: bool $aliasFields (optional) Should we alias the fields so they are the names param: array $addSQL (optional) Array of additional params to pass to the query. return: mixed False on error, or an array of nodes |
getParents($id, $keepAsArray = false, $aliasFields = true, $addSQL = array() X-Ref |
Fetch the parents of a node given by id param: int $id The node ID param: bool $keepAsArray (optional) Keep the result as an array or transform it into param: bool $aliasFields (optional) Should we alias the fields so they are the names param: array $addSQL (optional) Array of additional params to pass to the query. return: mixed False on error, or an array of nodes |
getParent($id, $keepAsArray = false, $aliasFields = true, $addSQL = array() X-Ref |
Fetch the immediate parent of a node given by id param: int $id The node ID param: bool $keepAsArray (optional) Keep the result as an array or transform it into param: bool $aliasFields (optional) Should we alias the fields so they are the names param: array $addSQL (optional) Array of additional params to pass to the query. return: mixed False on error, or the parent node |
getSiblings($id, $keepAsArray = false, $aliasFields = true, $addSQL = array() X-Ref |
Fetch all siblings of the node given by id Important: The node given by ID will also be returned Do a unset($array[$id]) on the result if you don't want that param: int $id The node ID param: bool $keepAsArray (optional) Keep the result as an array or transform it into param: bool $aliasFields (optional) Should we alias the fields so they are the names param: array $addSQL (optional) Array of additional params to pass to the query. return: mixed False on error, or the parent node |
getChildren($id, $keepAsArray = false, $aliasFields = true, $forceNorder = false, $addSQL = array() X-Ref |
Fetch the children _one level_ after of a node given by id param: int $id The node ID param: bool $keepAsArray (optional) Keep the result as an array or transform it into param: bool $aliasFields (optional) Should we alias the fields so they are the names param: bool $forceNorder (optional) Force the result to be ordered by the norder param: array $addSQL (optional) Array of additional params to pass to the query. return: mixed False on error, or an array of nodes |
getSubBranch($id, $keepAsArray = false, $aliasFields = true, $addSQL = array() X-Ref |
Fetch all the children of a node given by id getChildren only queries the immediate children getSubBranch returns all nodes below the given node param: string $id The node ID param: bool $keepAsArray (optional) Keep the result as an array or transform it into param: bool $aliasFields (optional) Should we alias the fields so they are the names param: array $addSQL (optional) Array of additional params to pass to the query. return: mixed False on error, or an array of nodes |
pickNode($id, $keepAsArray = false, $aliasFields = true, $idfield = 'id', $addSQL = array() X-Ref |
Fetch the data of a node with the given id param: int $id The node id of the node to fetch param: bool $keepAsArray (optional) Keep the result as an array or transform it into param: bool $aliasFields (optional) Should we alias the fields so they are the names param: string $idfield (optional) Which field has to be compared with $id? param: array $addSQL (optional) Array of additional params to pass to the query. return: mixed False on error, or an array of nodes |
isParent($parent, $child) X-Ref |
See if a given node is a parent of another given node A node is considered to be a parent if it resides above the child So it doesn't mean that the node has to be an immediate parent. To get this information simply compare the levels of the two nodes after you know that you have a parent relation. param: mixed $parent The parent node as array or object param: mixed $child The child node as array or object return: bool True if it's a parent |
createRootNode($values, $id = false, $first = false, $pos = NESE_MOVE_AFTER) X-Ref |
Creates a new root node. If no id is specified then it is either added to the beginning/end of the tree based on the $pos. Optionally it deletes the whole tree and creates one initial rootnode <pre> +-- root1 [target] | +-- root2 [new] | +-- root3 </pre> param: array $values Hash with param => value pairs of the node (see $this->params) param: integer $id ID of target node (the rootnode after which the node should be inserted) param: bool $first Danger: Deletes and (re)init's the hole tree - sequences are reset param: string $pos The position in which to insert the new node. return: mixed The node id or false on error |
createSubNode($id, $values) X-Ref |
Creates a subnode <pre> +-- root1 | +-\ root2 [target] | | | |-- subnode1 [new] | +-- root3 </pre> param: integer $id Parent node ID param: array $values Hash with param => value pairs of the node (see $this->params) return: mixed The node id or false on error |
createLeftNode($id, $values) X-Ref |
Creates a node before a given node <pre> +-- root1 | +-\ root2 | | | |-- subnode2 [new] | |-- subnode1 [target] | |-- subnode3 | +-- root3 </pre> param: int $id Target node ID param: array $values Hash with param => value pairs of the node (see $this->params) param: bool $returnID Tell the method to return a node id instead of an object. return: mixed The node id or false on error |
createRightNode($id, $values) X-Ref |
Creates a node after a given node <pre> +-- root1 | +-\ root2 | | | |-- subnode1 [target] | |-- subnode2 [new] | |-- subnode3 | +-- root3 </pre> param: int $id Target node ID param: array $values Hash with param => value pairs of the node (see $this->params) param: bool $returnID Tell the method to return a node id instead of an object. return: mixed The node id or false on error |
deleteNode($id) X-Ref |
Deletes a node param: int $id ID of the node to be deleted return: bool True if the delete succeeds |
updateNode($id, $values, $_internal = false) X-Ref |
Changes the payload of a node param: int $id Node ID param: array $values Hash with param => value pairs of the node (see $this->params) param: bool $_intermal Internal use only. Used to skip value validation. Leave this as it is. return: bool True if the update is successful |
moveTree($id, $targetid, $pos, $copy = false) X-Ref |
Wrapper for node moving and copying param: int $id Source ID param: int $target Target ID param: constant $pos Position (use one of the NESE_MOVE_* constants) param: bool $copy Shall we create a copy return: int ID of the moved node or false on error |
_moveAcross($source, $target, $pos, $first = false) X-Ref |
Moves nodes and trees to other subtrees or levels <pre> [+] <--------------------------------+ +-[\] root1 [target] | <-------------------------+ |p +-\ root2 | | | | | | | |-- subnode1 [target] | |B | |-- subnode2 [new] |S |E | |-- subnode3 |U |F | |B |O +-\ root3 | |R |-- subnode 3.1 | |E |-\ subnode 3.2 [source] >--+------+ |-- subnode 3.2.1 </pre> param: object $ NodeCT $source Source node param: object $ NodeCT $target Target node param: string $pos Position [SUBnode/BEfore] param: bool $copy Shall we create a copy |
_moveCleanup($copy = false) X-Ref |
Deletes the old subtree (node) and writes the node id's into the cloned tree param: array $relations Hash in der Form $h[alteid]=neueid param: array $copy Are we in copy mode? |
_moveRoot2Root($source, $target, $pos) X-Ref |
Moves rootnodes <pre> +-- root1 | +-\ root2 | | | |-- subnode1 [target] | |-- subnode2 [new] | |-- subnode3 | +-\ root3 [|] <-----------------------+ |-- subnode 3.1 [target] | |-\ subnode 3.2 [source] >--+ |-- subnode 3.2.1 </pre> param: object $ NodeCT $source Source param: object $ NodeCT $target Target param: string $pos BEfore | AFter |
_secSort($nodeSet) X-Ref |
OMG ... This is nasty |
_secSortCollect($segment, $deepArray, $reset = false) X-Ref |
Pas de description |
_addSQL($addSQL, $type, $prefix = false) X-Ref |
Adds a specific type of SQL to a query string param: array $addSQL The array of SQL strings to add. Example value: param: string $type The type of SQL. Can be 'cols', 'join', or 'append'. return: string The SQL, properly formatted |
_getSelectFields($aliasFields) X-Ref |
Gets the select fields based on the params param: bool $aliasFields Should we alias the fields so they are the names of the return: string A string of query fields to select |
_processResultSet($sql, $keepAsArray, $fieldsAreAliased) X-Ref |
Processes a DB result set by checking for a DB error and then transforming the result into a set of DB_NestedSet_Node objects or leaving it as an array. param: string $sql The sql query to be done param: bool $keepAsArray Keep the result as an array or transform it into a set of param: bool $fieldsAreAliased Are the fields aliased? return: mixed False on error or the transformed node set. |
_testFatalAbort($errobj, $file, $line) X-Ref |
Error Handler Tests if a given ressource is a PEAR error object ans raises a fatal error in case of an error object param: object $ PEAR::Error $errobj The object to test param: string $file The filename wher the error occured param: int $line The line number of the error return: void |
_raiseError($code, $mode, $option, $epr = array() X-Ref |
addListener($event, & $listener) X-Ref |
Add an event listener Adds an event listener and returns an ID for it <pre>Known events are nodeCreate nodeDelete nodeUpdate nodeCopy nodeLoad </pre> param: string $event The event name param: string $listener The listener object return: string |
removeListener($event, $listenerID) X-Ref |
Removes an event listener Removes the event listener with the given ID param: string $event The ivent name param: string $listenerID The listener's ID return: bool |
triggerEvent($event, & $node, $eparams = false) X-Ref |
Triggers and event an calls the event listeners param: string $event The Event that occured param: object $ node $node A Reference to the node object which was subject to changes param: array $eparams A associative array of params which may be needed by the handler return: bool |
apiVersion() X-Ref |
Pas de description |
setAttr($attr) X-Ref |
Sets an object attribute param: array $attr An associative array with attributes return: bool |
setsortMode($sortMode = false) X-Ref |
This enables you to set specific options for each output method param: constant $sortMode return: Current sortMode |
setDbOption($option, $val) X-Ref |
Sets a db option. Example, setting the sequence table format return: void |
testLock() X-Ref |
Tests if a database lock is set |
_setLock($exclusive = false) X-Ref |
_releaseLock($exclusive = false) X-Ref |
_lockGC() X-Ref |
_values2UpdateQuery($values, $addval = false) X-Ref |
_values2InsertQuery($values, $addval = false) X-Ref |
_verifyUserValues($caller, & $values) X-Ref |
Clean values from protected or unknown columns return: void |
_debugMessage($msg) X-Ref |
_getMessage($code) X-Ref |
convertTreeModel(& $orig, & $copy, $_parent = false) X-Ref |
Convert a <1.3 tree into a 1.3 tree format This will convert the tree into a format needed for some new features in 1.3. Your <1.3 tree will still work without converting but some new features like preorder sorting won't work as expected. <pre> Usage: - Create a new node table (tb_nodes2) from the current node table (tb_nodes1) (only copy the structure). - Create a nested set instance of the 'old' set (NeSe1) and one of the new set (NeSe2) - Now you have 2 identical objects where only node_table differs - Call DB_NestedSet::convertTreeModel(&$orig, &$copy); - After that you have a cleaned up copy of tb_nodes1 inside tb_nodes2 </pre> param: object $ DB_NestedSet $orig Nested set we want to copy param: object $ DB_NestedSet $copy Object where the new tree is copied to param: integer $_parent ID of the parent node (private) return: bool True uns success |
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |