1
0
mirror of synced 2025-01-06 09:07:09 +03:00

Fixed issue with isValidNode() not always being passed a Doctrine_Record and fixed issue with params being sent to set(), moved to where() until set() can handle params

This commit is contained in:
Jonathan.Wage 2007-08-02 20:05:12 +00:00
parent 9441f91d64
commit 48481be4bd

View File

@ -744,12 +744,14 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* *
* @return bool * @return bool
*/ */
public function isValidNode(Doctrine_Record $record = null) public function isValidNode($record = null)
{ {
if ($record === null) { if ($record === null) {
return ($this->getRightValue() > $this->getLeftValue()); return ($this->getRightValue() > $this->getLeftValue());
} else { } else if( $record instanceof Doctrine_Record ) {
return ($record->getNode()->getRightValue() > $record->getNode()->getLeftValue()); return ($record->getNode()->getRightValue() > $record->getNode()->getLeftValue());
} else {
return false;
} }
} }
@ -820,9 +822,9 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
// update level for descendants // update level for descendants
$q = new Doctrine_Query(); $q = new Doctrine_Query();
$q = $q->update($componentName) $q = $q->update($componentName)
->set($componentName . '.level', 'level + ?', $levelDiff) ->set($componentName . '.level', 'level + ?')
->where($componentName . '.lft > ? AND ' . $componentName . '.rgt < ?', ->where($componentName . '.lft > ? AND ' . $componentName . '.rgt < ?',
array($left, $right)); array($levelDiff, $left, $right));
$q = $this->_tree->returnQueryWithRootId($q, $rootId); $q = $this->_tree->returnQueryWithRootId($q, $rootId);
$q->execute(); $q->execute();
@ -850,8 +852,8 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
// shift left columns // shift left columns
$componentName = $this->_tree->getBaseComponent(); $componentName = $this->_tree->getBaseComponent();
$qLeft = $qLeft->update($componentName) $qLeft = $qLeft->update($componentName)
->set($componentName . '.lft', 'lft + ?', $delta) ->set($componentName . '.lft', 'lft + ?')
->where($componentName . '.lft >= ?', $first); ->where($componentName . '.lft >= ?', array($delta, $first));
$qLeft = $this->record->getTable()->getTree()->returnQueryWithRootId($qLeft, $rootId); $qLeft = $this->record->getTable()->getTree()->returnQueryWithRootId($qLeft, $rootId);
@ -859,8 +861,8 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
// shift right columns // shift right columns
$resultRight = $qRight->update($componentName) $resultRight = $qRight->update($componentName)
->set($componentName . '.rgt', 'rgt + ?', $delta) ->set($componentName . '.rgt', 'rgt + ?')
->where($componentName . '.rgt >= ?', $first); ->where($componentName . '.rgt >= ?', array($delta, $first));
$qRight = $this->record->getTable()->getTree()->returnQueryWithRootId($qRight, $rootId); $qRight = $this->record->getTable()->getTree()->returnQueryWithRootId($qRight, $rootId);
@ -883,8 +885,8 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
// shift left column values // shift left column values
$componentName = $this->_tree->getBaseComponent(); $componentName = $this->_tree->getBaseComponent();
$qLeft = $qLeft->update($componentName) $qLeft = $qLeft->update($componentName)
->set($componentName . '.lft', 'lft + ?', $delta) ->set($componentName . '.lft', 'lft + ?')
->where($componentName . '.lft >= ? AND ' . $componentName . '.lft <= ?', array($first, $last)); ->where($componentName . '.lft >= ? AND ' . $componentName . '.lft <= ?', array($delta, $first, $last));
$qLeft = $this->record->getTable()->getTree()->returnQueryWithRootId($qLeft, $rootId); $qLeft = $this->record->getTable()->getTree()->returnQueryWithRootId($qLeft, $rootId);
@ -892,8 +894,8 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
// shift right column values // shift right column values
$qRight = $qRight->update($componentName) $qRight = $qRight->update($componentName)
->set($componentName . '.rgt', 'rgt + ?', $delta) ->set($componentName . '.rgt', 'rgt + ?')
->where($componentName . '.rgt >= ? AND ' . $componentName . '.rgt <= ?', array($first, $last)); ->where($componentName . '.rgt >= ? AND ' . $componentName . '.rgt <= ?', array($delta, $first, $last));
$qRight = $this->record->getTable()->getTree()->returnQueryWithRootId($qRight, $rootId); $qRight = $this->record->getTable()->getTree()->returnQueryWithRootId($qRight, $rootId);