예제 #1
0
 /**
  * Move current node and its children to location $destLeft and updates rest of tree
  *
  * @param      int	$destLeft Destination left value
  * @param      int	$levelDelta Delta to add to the levels
  * @param      PropelPDO $con		Connection to use.
  */
 protected function moveSubtreeTo($destLeft, $levelDelta, PropelPDO $con = null)
 {
     $preventDefault = false;
     $left = $this->getLeftValue();
     $right = $this->getRightValue();
     $treeSize = $right - $left + 1;
     if ($con === null) {
         $con = Propel::getConnection(PagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         // make room next to the target for the subtree
         PagePeer::shiftRLValues($treeSize, $destLeft, null, $con);
         if (!$preventDefault) {
             if ($left >= $destLeft) {
                 // src was shifted too?
                 $left += $treeSize;
                 $right += $treeSize;
             }
             if ($levelDelta) {
                 // update the levels of the subtree
                 PagePeer::shiftLevel($levelDelta, $left, $right, $con);
             }
             // move the subtree to the target
             PagePeer::shiftRLValues($destLeft - $left, $left, $right, $con);
         }
         // remove the empty room at the previous location of the subtree
         PagePeer::shiftRLValues(-$treeSize, $right + 1, null, $con);
         // update all loaded nodes
         PagePeer::updateLoadedNodes(null, $con);
         $con->commit();
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
예제 #2
0
 /**
  * Update the tree to allow insertion of a leaf at the specified position
  *
  * @param      int $left	left column value
  * @param      mixed $prune	Object to prune from the shift
  * @param      PropelPDO $con	Connection to use.
  */
 public static function makeRoomForLeaf($left, $prune = null, PropelPDO $con = null)
 {
     // Update database nodes
     PagePeer::shiftRLValues(2, $left, null, $con);
     // Update all loaded nodes
     PagePeer::updateLoadedNodes($prune, $con);
 }