Esempio n. 1
0
 /**
  * Get node properties from propel object.
  *
  * @param mixed|BaseObject $instance
  * @param Curry_Tree $tree
  * @param int $depth
  * @return array
  */
 public function objectToJson($instance, Curry_Tree $tree, $depth = 0)
 {
     $p = array('title' => (string) $instance, 'key' => (string) $instance->getPrimaryKey());
     if ($instance->hasChildren()) {
         $p['children'] = array();
         if ($this->lazy) {
             $p['isLazy'] = true;
         }
     }
     return $p;
 }
 /**
  * Runs necessary queries before node is deleted.
  * 
  * @param      BaseObject  $node
  */
 public function preDelete(BaseObject $node)
 {
     $peer_name = get_class($node->getPeer());
     $this->addPreDeleteStackEntries(self::shiftRLRange($peer_name, $node->getLeftValue(), $node->getRightValue(), -1, $node->getScopeIdValue()));
     $this->addPreDeleteStackEntries(self::shiftRLValues($peer_name, $node->getRightValue() + 1, -2, $node->getScopeIdValue()));
     // Take care of adjacency parameters
     if ($node->hasChildren()) {
         $peer_name = get_class($node->getPeer());
         $node_class = get_class($node);
         $query = sprintf('UPDATE %s SET %s = %s WHERE %s = %s', constant("{$peer_name}::TABLE_NAME"), self::getColumnConstant($node_class, 'parent', true), $node->getParentIdValue(), self::getColumnConstant($node_class, 'parent'), $node->getPrimaryKey());
         $con = Propel::getConnection();
         $statement = $con->createStatement();
         $statement->execute($query);
     }
     $this->processPreDeleteStack();
 }